// If we have an error and want to fail fast, return
if errors.len() > 0 && !options.no_fail_fast {
- return Ok(Some(CargoTestError::from(&errors[..])))
+ return Ok(Some(CargoTestError::new(errors)))
}
// If a specific test was requested or we're not running any tests at all,
if let ops::CompileFilter::Only { .. } = options.compile_opts.filter {
match errors.len() {
0 => return Ok(None),
- _ => return Ok(Some(CargoTestError::from(&errors[..])))
+ _ => return Ok(Some(CargoTestError::new(errors)))
}
}
if errors.len() == 0 {
Ok(None)
} else {
- Ok(Some(CargoTestError::from(&errors[..])))
+ Ok(Some(CargoTestError::new(errors)))
}
}
let errors = try!(run_unit_tests(options, &args, &compilation));
match errors.len() {
0 => Ok(None),
- _ => Ok(Some(CargoTestError::from(&errors[..]))),
+ _ => Ok(Some(CargoTestError::new(errors))),
}
}
}
impl<T, E: CargoError + 'static> ChainError<T> for Result<T, E> {
- #[allow(trivial_casts)]
fn chain_error<E2: 'static, C>(self, callback: C) -> CargoResult<T>
where E2: CargoError, C: FnOnce() -> E2 {
self.map_err(move |err| {
impl Error for ProcessError {
fn description(&self) -> &str { &self.desc }
- #[allow(trivial_casts)]
fn cause(&self) -> Option<&Error> {
self.cause.as_ref().map(|s| s as &Error)
}
pub struct CargoTestError {
pub desc: String,
pub exit: Option<ExitStatus>,
- cause: Option<io::Error>,
+ pub causes: Vec<ProcessError>,
+}
+
+impl CargoTestError {
+ #[allow(deprecated)] // connect => join in 1.3
+ pub fn new(errors: Vec<ProcessError>) -> Self {
+ if errors.len() == 0 {
+ panic!("Cannot create CargoTestError from empty Vec")
+ }
+ let desc = errors.iter().map(|error| error.desc.clone())
+ .collect::<Vec<String>>()
+ .connect("\n");
+ CargoTestError {
+ desc: desc,
+ exit: errors[0].exit,
+ causes: errors,
+ }
+ }
}
impl fmt::Display for CargoTestError {
impl Error for CargoTestError {
fn description(&self) -> &str { &self.desc }
- #[allow(trivial_casts)]
fn cause(&self) -> Option<&Error> {
- self.cause.as_ref().map(|s| s as &Error)
- }
-}
-
-#[allow(deprecated)] // connect => join in 1.3
-impl<'a> From<&'a [ProcessError]> for CargoTestError {
- fn from(errors: &[ProcessError]) -> Self {
- if errors.len() == 0 { panic!("Cannot create CargoTestError from empty Vec") }
- let desc = errors.iter().map(|error| error.desc.clone()).collect::<Vec<String>>().connect("\n");
- CargoTestError {
- desc: desc,
- exit: errors[0].exit,
- cause: None,
- }
+ self.causes.get(0).map(|s| s as &Error)
}
}